import { z } from "zod";

import { getTagListMapper } from "../sql";
import { TagTypeEnum } from "@prisma/client";

export const verifyCreateTag = z.object({
  name: z.string().min(1, { message: "长度不能少于1个字符" }),
  type: z.enum([TagTypeEnum.ALL, TagTypeEnum.BLOG]),
});

export const verifyUpdateTag = verifyCreateTag.partial().extend({
  id: z.string().min(1),
});

export const verifyGetTagList = z.object({
  name: z.string().optional(),
  type: z.enum([TagTypeEnum.ALL, TagTypeEnum.BLOG]).optional(),
  pageIndex: z.number(),
  pageSize: z.number(),
});

export type CreateTagDTO = z.infer<typeof verifyCreateTag>;
export type UpdateTagDTO = z.infer<typeof verifyUpdateTag>;
export type GetTagListDTO = z.infer<typeof verifyGetTagList>;

export type Tag = Awaited<ReturnType<typeof getTagListMapper>>["tags"][number];
